from appium import webdriver
from appium.options.android import UiAutomator2Options

from tests.app.pages.base_page import BasePage



class Wecom(BasePage):
    def start_app(self):
        caps = {
            "platformName": "Android",
            # driver的类型
            "appium:automationName": "uiautomator2",
            # 被测应用
            "appium:appPackage": "com.tencent.wework",
            "appium:appActivity": ".launch.LaunchSplashActivity",
            # 版本
            "appium:platformVersion": "12",
            # 执行完成之后是否停止app
            "appium:shouldTerminateApp": True,
            # 启动driver的时候是否强制启动app
            "appium:forceAppLaunch": True,
            # 不重置app
            "appium:noReset": True

        }
        self.driver = webdriver.Remote("http://127.0.0.1:4723",
                                           options=UiAutomator2Options().load_capabilities(caps))
        self.driver.implicitly_wait(10)
        return self

    def quit_app(self):
        self.driver.quit()
    def goto_main(self):
        from tests.app.pages.main_page import MainPage
        return MainPage(self.driver)